var fileWorkPicType = [".jpg",".gif",".jpeg",".png",".bmp",".zip",".rar",".xls",".xlsx",".doc",".ppt",".txt",".pdf"];
var fileVideoType = [".rm",".rmvb",".avi",".3gp",".mp4",".mkv",".flv",".wmv"];

/**
 * 根据文件的后缀 获取文件类型 1 表示文档图片 2表示视频
 * @param fileType
 * @returns {Number}
 */
function getFileType (fileType){
	var reType = 0;
	for(var i=0;i<fileWorkPicType.length;i++){
		if(fileType == fileWorkPicType[i]){
			reType =  1;
			break;
		}
	}
	for(var i=0;i<fileVideoType.length;i++){
		if(fileType == fileVideoType[i]){
			reType = 2;
			break;
		}
	}
	return reType;
};

function showFormInputNullTip(inputValue,tipMsg,condition){
	if(condition == undefined || condition == null){
		condition = (inputValue == null || inputValue == undefined ||inputValue == '');
	}
	if(condition){
		sAlert(tipMsg);
		return true;
	} 
	return false;
};

/**
 * 用于check 选择的值 用@字符串拼接
 */
function getValuesByJqueryObjs($obj){
	var ids = '';
	for(var i = 0;i<$obj.length;i++){
		if(i == $obj.length-1){
			ids += $($obj[i]).val();
		}else{
			ids += $($obj[i]).val()+"@";
		}
	}
	return ids;
};

/**
 * 获取树的节点id 用@字符串拼接
 * @param nodes
 * @returns {String}
 */
function getValuesByZtreeObjs(nodes){
	var ids = '';
	for(var i = 0;i<nodes.length;i++){
		if(i == nodes.length-1){
			ids += nodes[i].id;
		}else{
			ids += nodes[i].id+"@";
		}
	}
	return ids;
};




Array.prototype.indexOf = function(val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i].id == val) return i;
    }
    return -1;
};

Array.prototype.remove = function(val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};


function sAlert(msg){
	swal(msg);
};


function deleteConfirm(fn){
	
	swal({ title: "确定删除?",  
		   type: "warning",   
		   showCancelButton: true,  
		   confirmButtonColor: "#DD6B55",  
		   confirmButtonText: "确定",
		 //  cancelButtonText:"取消",
		   closeOnConfirm: false 
		   },
		   function(){
			   fn();
		   });
};

